package angle;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

import com.opensymphony.xwork2.ActionContext;

import common.BaseAction;
import utils.CodeUtil;

public class CodeAngle extends BaseAction {
	private static final long serialVersionUID = 6894525175454169331L;

	private String code;
	private int width = 80;
	private int height = 30;
	private int fontSize = 20;
	private int codeLength = 4;


	public String code() throws Exception {
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		code = new CodeUtil().createCode(1, fontSize, bos, width, height, codeLength);
		ActionContext.getContext().getSession().put("code", code);
		inputStream = new ByteArrayInputStream(bos.toByteArray());
		bos.reset();
		bos.close();
		return SUCCESS;
	}

	//////////////////

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public int getFontSize() {
		return fontSize;
	}

	public void setFontSize(int fontSize) {
		this.fontSize = fontSize;
	}

	public int getCodeLength() {
		return codeLength;
	}

	public void setCodeLength(int codeLength) {
		this.codeLength = codeLength;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	
	
}
